package com.mew.common.entity.config;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mew.common.exception.ResponseCode;
import lombok.*;

@TableName("c_error_code")
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ErrorCode {

    @TableId(value = "code")
    private Integer code; //错误码

    @TableField("code_type")
    private Integer codeType; //错误码类型

    @TableField("default_langue")
    private String defaultLangue;  // 母语

    @TableField("chinese")
    private String chinese;  //中文

    @TableField("tradition")
    private String tradition; //繁体

    @TableField("english")
    private String english;  // 英语

    @TableField("thailand")
    private String thailand;  // thailand

    public ErrorCode buildData(ResponseCode ec){
        this.setCode(ec.code());
        this.setCodeType(ec.codeType());
        this.setDefaultLangue(ec.msg());
        this.setChinese(ec.msg());
        this.setTradition(ec.msg());
        this.setEnglish(ec.name());
        this.setThailand(ec.msg());
        return this;
    }

    public void buildData(ErrorCode dbErrorCode){
        this.setDefaultLangue(dbErrorCode.getDefaultLangue());
        this.setChinese(dbErrorCode.getChinese());
        this.setTradition(dbErrorCode.getTradition());
        this.setEnglish(dbErrorCode.getEnglish());
        this.setThailand(dbErrorCode.getThailand());
    }


}
